package main

import (
	"crypto/des"
	"fmt"
	"log"
)

func main() {
	key := []byte("android_keys")
	originData := "abc"
	en, err := TripleDesEncrypt(originData, key)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(en)
}

func TripleDesEncrypt(origData, key []byte) ([]byte, error) {
	block, err := des.NewTripleDESCipher(key)
	if err != nil {
		return nil, err
	}
	origData = PKCS5Padding(origData, block.BlockSize())
	blockMode := cipher.NewCBCEncrypter(block, key[:8])
	crypted := make([]byte, len(origData))
	blockMode.CryptBlocks(crypted, origData)
	return crypted, nil
}
